package com.caigou.comm.base.container

import android.app.Application
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.caigou.comm.base.utils.Logger
import com.caigou.comm.base.utils.Prefs
import com.tencent.smtt.export.external.TbsCoreSettings
import com.tencent.smtt.sdk.QbSdk


/**
 * @author #Suyghur.
 * Created on 2021/09/13
 */
open class BaseApplication : Application() {

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        context = this
        Logger.initZap(this)
        Prefs.instance.init(this)
        ARouter.openLog()
        ARouter.openDebug()
        ARouter.init(this)

        // 在调用TBS初始化、创建WebView之前进行如下配置
        val map = HashMap<String, Any>()
        map[TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER] = true
        map[TbsCoreSettings.TBS_SETTINGS_USE_DEXLOADER_SERVICE] = true
        QbSdk.initTbsSettings(map)
    }

    override fun onCreate() {
        super.onCreate()
    }

    companion object {
        private var context: BaseApplication? = null
        fun getContext(): Context {
            return context!!
        }
    }
}